--苦难陈述
local kunanchengshu = fk.CreateSkill {
    name = "mcdh_kunanchengshu",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

kunanchengshu:addEffect(fk.EventPhaseStart,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and target == player and player.phase == Player.Start
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local targets,card =room:askForChooseCardAndPlayers(player,table.map(room:getOtherPlayers(player),Util.IdMapper),1,1,".","#kunanchengshu",self.name,true)
        if #targets ~= 0 then
            self.cost_data = {targets[1],card}
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:throwCard(self.cost_data[2], self.name, player, player)
        room:setPlayerMark(player,"kunanchengshu",{self.cost_data[1]})
    end
})

kunanchengshu:addEffect(fk.TurnStart,{
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        return target == player and player:getMark("kunanchengshu") ~= 0
    end,
    on_trigger = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player,"kunanchengshu",0)
    end,
})

kunanchengshu:addEffect('distance',{
    correct_func = function(self, from, to)
        if from:getMark("kunanchengshu") ~= 0 then
            if table.contains(from:getMark("kunanchengshu"),to.id) then
                return 1
            end
        end
        if to:getMark("kunanchengshu") ~= 0 then
            if table.contains(to:getMark("kunanchengshu"),from.id) then
                return 1
            end
        end
    end,
})

Fk:loadTranslationTable{
    ["mcdh_kunanchengshu"] = "述难",
    [":mcdh_kunanchengshu"] ="『苦难陈述』<br>准备阶段，你可以弃置一张牌并选择一名其他角色，直到你的下一个回合开始，你与其计算互相的距离+1。",
    ["#kunanchengshu"] = "苦难陈述：弃置一张牌并选择一名其他角色，直到你的下一个回合开始，你与其计算互相的距离+1。"
}
return kunanchengshu